<%@ page import="com.xszx.entity.TUser" %><%--
  Created by IntelliJ IDEA.
  User: 32312
  Date: 2024/1/9
  Time: 10:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
<%
    TUser user = (TUser)request.getSession().getAttribute("user");
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="/resource/materialize/css/materialize.min.css" media="screen,projection" />
    <!-- Bootstrap Styles-->
    <link href="/resource/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="/resource/css/font-awesome.css" rel="stylesheet" />
    <!-- Morris Chart Styles-->
    <link href="/resource/js/morris/morris-0.4.3.min.css" rel="stylesheet" />
    <!-- Custom Styles-->
    <link href="/resource/css/custom-styles.css" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="/resource/js/Lightweight-Chart/cssCharts.css">
  <script src="/resource/js/jquery-1.7.1.js"></script>

</head>
<body>
<div id="wrapper">
    <nav class="navbar navbar-default top-navbar" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand waves-effect waves-dark" href="/jsp/index.jsp"><i class="large material-icons">insert_chart</i> <strong>TRACK</strong></a>

            <div id="sideNav" href=""><i class="material-icons dp48">toc</i></div>
        </div>

        <ul class="nav navbar-top-links navbar-right">
            <li><a class="dropdown-button waves-effect waves-dark" href="#!" data-activates="dropdown1"><i class="fa fa-user fa-fw"></i> <b>${user.username}</b> </a></li>
        </ul>
    </nav>
    <!-- Dropdown Structure -->
    <ul id="dropdown1" class="dropdown-content">
        <li><a href="/jsp/form.jsp"><i class="fa fa-user fa-fw"></i> 个人中心</a>
        </li>
        <li><a href="/jsp/personCenter.jsp"><i class="fa fa-bell fa-fw"></i> 个人任务</a>
        </li>
        <li><a href="/jsp/test.jsp" target="_top"><i class="fa fa-sign-out fa-fw"></i> 注销</a>
        </li>
    </ul>
    <ul id="dropdown2" class="dropdown-content w250">
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-comment fa-fw"></i> New Comment
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-twitter fa-fw"></i> 3 New Followers
                    <span class="pull-right text-muted small">12 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-envelope fa-fw"></i> Message Sent
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-tasks fa-fw"></i> New Task
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-upload fa-fw"></i> Server Rebooted
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a class="text-center" href="#">
                <strong>See All Alerts</strong>
                <i class="fa fa-angle-right"></i>
            </a>
        </li>
    </ul>
    <ul id="dropdown3" class="dropdown-content dropdown-tasks w250">
        <li>
            <a href="#">
                <div>
                    <p>
                        <strong>Task 1</strong>
                        <span class="pull-right text-muted">60% Complete</span>
                    </p>
                    <div class="progress progress-striped active">
                        <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
                            <span class="sr-only">60% Complete (success)</span>
                        </div>
                    </div>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <p>
                        <strong>Task 2</strong>
                        <span class="pull-right text-muted">28% Complete</span>
                    </p>
                    <div class="progress progress-striped active">
                        <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="28" aria-valuemin="0" aria-valuemax="100" style="width: 28%">
                            <span class="sr-only">28% Complete</span>
                        </div>
                    </div>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <p>
                        <strong>Task 3</strong>
                        <span class="pull-right text-muted">60% Complete</span>
                    </p>
                    <div class="progress progress-striped active">
                        <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
                            <span class="sr-only">60% Complete (warning)</span>
                        </div>
                    </div>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <p>
                        <strong>Task 4</strong>
                        <span class="pull-right text-muted">85% Complete</span>
                    </p>
                    <div class="progress progress-striped active">
                        <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="85" aria-valuemin="0" aria-valuemax="100" style="width: 85%">
                            <span class="sr-only">85% Complete (danger)</span>
                        </div>
                    </div>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
    </ul>
    <ul id="dropdown4" class="dropdown-content dropdown-tasks w250">
        <li>
            <a href="#">
                <div>
                    <strong>John Doe</strong>
                    <span class="pull-right text-muted">
                                        <em>Today</em>
                                    </span>
                </div>
                <div>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s...</div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <strong>John Smith</strong>
                    <span class="pull-right text-muted">
                                        <em>Yesterday</em>
                                    </span>
                </div>
                <div>Lorem Ipsum has been the industry's standard dummy text ever since an kwilnw...</div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <strong>John Smith</strong>
                    <span class="pull-right text-muted">
                                        <em>Yesterday</em>
                                    </span>
                </div>
                <div>Lorem Ipsum has been the industry's standard dummy text ever since the...</div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a class="text-center" href="#">
                <strong>Read All Messages</strong>
                <i class="fa fa-angle-right"></i>
            </a>
        </li>
    </ul>
    <!--/. NAV TOP  -->
    <!--/. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">


                <li>
                    <a class="active-menu waves-effect waves-dark" href="/jsp/index.jsp"><i class="fa fa-dashboard"></i> 统计</a>
                </li>

                <li>
                    <a href="#" class="waves-effect waves-dark"><i class="fa fa-sitemap"></i>固定资产管理<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li>
                            <a href="#">资产管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li>
                                    <a href="/jsp/assetTable.jsp">总资产管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetFixTable.jsp">维修资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetForbiddenTable.jsp">禁用资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetFreeTable.jsp">空闲资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetScrapTable.jsp">报废资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetUsingTable.jsp">使用中资产</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href="/jsp/recordTable.jsp">合同管理</a>
                        </li>
                        <li>
                            <a href="#">系统管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li>
                                    <a href="/jsp/deptTable.jsp">部门管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/user.jsp">用户管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/roleTable.jsp">角色管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/menuTable.jsp">菜单管理</a>
                                </li>
                            </ul>

                        </li>
                    </ul>
                </li>
                <li>
                    <a href="/jsp/empty.jsp" class="waves-effect waves-dark"><i class="fa fa-fw fa-file"></i> 日志</a>
                </li>
            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper" >
        <div class="header">
            <h1 class="page-header">
                用户角色管理
            </h1>
            <ol class="breadcrumb">
                <li><a href="#">Home</a></li>
                <li><a href="#">用户角色管理</a></li>
                <li class="active">数据</li>
            </ol>

        </div>

        <div id="page-inner">

            <div class="row">
                <div class="col-md-12">
                    <!--    Hover Rows  -->
                    <div class="card">
                        <div class="card-content">
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>角色ID</th>
                                        <th>角色名称</th>
                                        <th >操作</th>
                                    </tr>
                                    </thead>
                                    <tbody name="roleTable">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <!-- End  Hover Rows  -->
                </div>
            </div>



            <footer><p>Copyright &copy; 2016.Company name All rights reserved.<a target="_blank" href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a></p></footer>
        </div>
        <!-- /. PAGE INNER  -->


        </div><!--/.modal -->
    </div>
    <!-- /. PAGE WRAPPER  -->
    <!-- /. WRAPPER  -->
    <!-- JS Scripts-->

#  表格
    <script>


        $(function(){
            $.ajax({
                url:"/selectRoles",
                type:"POST",
                //数据形式
                dataType:"json",
                //请求成功后调用的回调函数
                success:function (data) {
                    console.log(data);
                    for (var i = 0;i<data.length;i++){
                        $("[name=roleTable]").append(
                            "<tr class=\"gradeU\">\n"+
                            "   <td>"+ data[i].rid+ "</td>\n"+
                            "   <td>"+ data[i].rname+ "</td>\n"+
                            "   <td>\n"+
                            "     <button class=btn signin_btn data-toggle=modal  onclick=del("+data[i].rid+")>删除</button>\n"+
                            "     </td>\n"+
                            "     </tr>"
                        );
                    }
                }
            });
            $.ajax({
                //请求资源路径
                url:"/selectMenus",
                //是否异步  一般不写
                async:true,
                //请求参数
                //请求方式
                type:"POST",
                //数据形式
                dataType:"json",
                //请求成功后调用的回调函数
                success:function (data) {
                    console.log(data);
                    for (var i = 0;i<data.length;i++){
                        $("[name='menus']").append(
                            " <input name=\"sex\" type=\"checkbox\" id=\""+i+"\" />\n" +
                            "                        <label for=\""+i+"\" style=\"font-size: 15px\">男</label>"
                        )
                    }
                }
            });
        })



        $("#add").click(function ()
        {

            if($("#dname").val()==""||$("#dsum").val()==""){
                alert("信息不能为空，请重新输入");
            }else{
                $.ajax({
                        url:"/addDept",
                        data:{
                            rname:$("#rname").val(),
                            menu:$("#menu").val()
                        },
                        type:"post",
                    dataType:"json",
                        success:function (data) {
                            console.log(data);
                            if(data == "0"){
                                alert("该部门已存在！")
                            }else{
                                alert("添加成功")
                                location.href="/jsp/deptTable.jsp";
                            }
                        }
                    }
                )
            }
        })

        $("#update").click(function () {
                $.ajax({
                        url:"/updateDept",
                        data:{
                            did:$("#updid").val(),
                            dname:$("#updname").val(),
                            dsum:$("#updsum").val()
                        },
                        type:"post",
                        dataType:"json",
                        success:function (data) {
                            console.log(data);
                            if(data <= 0){
                                alert("修改失败！您修改后的部门可能已存在！")
                            }else{
                                alert("修改成功");
                                location.href="/jsp/deptTable.jsp";
                            }
                        }
                    }
                )
        })
    </script>

<script>

    function del(rid){
        var r = confirm("确定删除此条数据？");
        if (r == true) {
            $.ajax({
                url:"/deleteRoel",
                data:{
                    rid:rid
                },
                type:"post",
                dataType:"json",
                success:function (data) {
                    console.log(data);
                    if(data <= 0){
                        alert("删除失败！");
                        r = false;
                    }else{
                        alert("删除成功!");
                        location.href="/jsp/roleTable.jsp";
                    }
                }
            })
        }else{
            r = false;
        }
    }

    function update(did){
        $.ajax({
            url:"/getDeptByDid",
            type:"post",
            data:{
                did:did
            },
            dataType:"json",
            success:function (data) {
                console.log(data);
                $("[name=updid]").val(data.did) ;
               $("[name=updname]").val(data.dname);
                $("[name=updsum]").val(data.dsum);
            }
        })

    }

</script>

    <script>

    </script>
    <!-- Custom Js -->
    <script src="/resource/js/custom-scripts.js"></script>
<!-- jQuery Js -->
<script src="/resource/js/jquery-1.10.2.js"></script>

<!-- Bootstrap Js -->
<script src="/resource/js/bootstrap.min.js"></script>

<script src="/resource/materialize/js/materialize.min.js"></script>

<!-- Metis Menu Js -->
<script src="/resource/js/jquery.metisMenu.js"></script>
<!-- Morris Chart Js -->
<script src="/resource/js/morris/raphael-2.1.0.min.js"></script>
<script src="/resource/js/morris/morris.js"></script>


<script src="/resource/js/easypiechart.js"></script>
<script src="/resource/js/easypiechart-data.js"></script>

<script src="/resource/js/Lightweight-Chart/jquery.chart.js"></script>

<!-- Custom Js -->
<script src="/resource/js/custom-scripts.js"></script>


</div>
</body>

</html>

